package com.gec.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.ITripItinerary;
import com.gec.model.system.ITripService;
import com.gec.model.system.ITripSights;
import com.gec.model.system.ITripUser;
import com.gec.model.vo.ITripSightQueryVo;
import com.gec.system.mapper.ITripSightsMapper;
import com.gec.system.service.ITripSightsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 景点表 服务实现类
 * </p>
 *
 * @author dafei
 * @since 2024-01-22
 */
@Service
public class ITripSightsServiceImpl extends ServiceImpl<ITripSightsMapper, ITripSights> implements ITripSightsService {

    @Override
    public IPage<ITripSights> selectPage(IPage<ITripSights> page1, ITripSightQueryVo iTripSightQueryVo) {
        IPage<ITripSights> iPage = this.baseMapper.selectPage(page1, iTripSightQueryVo, null);
        return iPage;
    }

    @Override
    public List<ITripSights> selectPage() {
        List<ITripSights> list = this.selectPage();
        return list;
    }

    @Override
    public void updateActivated(Long id, Integer status) {
        //1.查询出当前用户
        ITripSights iTripSights = this.baseMapper.selectById(id);
        //2.设置状态
        iTripSights.setIsActivated(status);
        //3.更新
        this.baseMapper.updateById(iTripSights);
    }

    @Override
    public ITripSights selectByName(String sightsName) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("sightsName",sightsName);//相当于where typeNo=1
        List<ITripSights> list = baseMapper.selectList(wrapper);
        return list.size()==0 ?null :list.get(0);
    }

    @Override
    public List<ITripSights> selectByCityId(Long cityId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("cityId",cityId);//相当于where typeNo=1
        List<ITripSights> list = baseMapper.selectList(wrapper);
        return list.size()==0 ?null :list;
    }

    @Override
    public List<ITripSights> getByIsGood() {
        List<ITripSights> list = baseMapper.getByIsGood();
        return list;
    }


}
